package com.neuedu.yyzx.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neuedu.yyzx.dto.NurseRecordDTO;
import com.neuedu.yyzx.po.Nurserecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author HordEmpty
 * @description 针对表【nurserecord】的数据库操作Mapper
 * @createDate 2025-04-09 10:13:49
 * @Entity com.neuedu.yyzx.po.Nurserecord
 */
public interface NurserecordMapper extends BaseMapper<Nurserecord> {
    @Select({
            "<script>",
            "SELECT c.*, cc.customer_name, us.nickname, nt.nursing_name ",
            "FROM nurserecord c ",
            "LEFT JOIN customer cc ON c.customer_id = cc.customer_id ",
            "LEFT JOIN user us ON c.user_id = us.id ",
            "LEFT JOIN nursecontent nt ON c.item_id = nt.id ",
            "<where>",
            "  c.is_deleted = 0", // 明确指定表名为 c (customernurseitem)
            "  <if test='ew != null and ew.sqlSegment != null and ew.sqlSegment.trim() != \"\"'>",
            "    AND ${ew.sqlSegment.replaceAll(\"customer_id\", \"c.customer_id\")}", // 动态条件中替换为明确的表名
            "  </if>",
            "</where>",
            "</script>"
    })
    IPage<NurseRecordDTO> pageDetails(@Param("page") Page<NurseRecordDTO> page, @Param("ew") LambdaQueryWrapper<Nurserecord> queryWrapper);
}




